package com.jwb.demo001;

import com.jwb.demo001.event.DemoEvent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;

import java.util.Locale;

@SpringBootApplication
public class Demo001Application {


    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(Demo001Application.class, args);

        Demo001Application bean = applicationContext.getBean(Demo001Application.class);
        System.out.println("容器中获取的bean：" + bean);

        Environment environment = applicationContext.getEnvironment();
        System.out.println("系统环境变量 PATH = " + environment.getProperty("PATH"));
        System.out.println("配置文件 my.user.name = " + environment.getProperty("my.user.name"));

        System.out.println(applicationContext.getResource("classpath:application.properties"));
        System.out.println(applicationContext.getResource("classpath*:spring.fatories"));

        System.out.println("HI 的英文意思：" + applicationContext.getMessage("HI", null, Locale.ENGLISH));
        System.out.println("HI 的中文意思：" + applicationContext.getMessage("HI", null, Locale.CHINA));

        DemoEvent event = new DemoEvent(Demo001Application.class, "这是测试的广播");
        applicationContext.publishEvent(event);
    }

}
